﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestPressure
{
    internal class Config
    {
        #region
        /// <summary>配置文件路径
        /// 
        /// </summary>
        static String configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini");

        /// <summary>ini文件操作工具
        /// 
        /// </summary>
        private static IniFile ini = new IniFile(configPath);

        /// <summary>播报测试数据
        /// 
        /// </summary>
        private static string BroadcastTestDataKey = "BroadcastTestData";

        /// <summary>播报远端异常
        /// 
        /// </summary>
        private static string BroadcastRemoteErrorKey = "BroadcastRemoteError";

        /// <summary>播报压差
        /// 
        /// </summary>
        private static string BroadcastPressureIntervalKey = "BroadcastPressureInterval";

        /// <summary>播报启动
        /// 
        /// </summary>
        private static string BroadcastStartKey = "BroadcastStart";
        #endregion

        #region

        /// <summary> 播报测试数据
        /// 
        /// </summary>
        public static bool BroadcastTestData
        {
            get
            {
                return ini.ReadBool(BroadcastTestDataKey, "Enable", true);
            }
            set
            {
                ini.Write(BroadcastTestDataKey, "Enable", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报测试数据时间间隔
        /// 
        /// </summary>
        public static int BroadcastTestDataTimeInterval
        {
            get
            {
                return ini.ReadInt(BroadcastTestDataKey, "TimeInterval", 5);
            }
            set
            {
                ini.Write(BroadcastTestDataKey, "TimeInterval", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报远端异常
        /// 
        /// </summary>
        public static bool BroadcastRemoteError
        {
            get
            {
                return ini.ReadBool(BroadcastRemoteErrorKey, "Enable", false);
            }
            set
            {
                ini.Write(BroadcastRemoteErrorKey, "Enable", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报远端异常间隔
        /// 
        /// </summary>
        public static int BroadcastRemoteErrorTimeInterval
        {
            get
            {
                return ini.ReadInt(BroadcastRemoteErrorKey, "TimeInterval", 5);
            }
            set
            {
                ini.Write(BroadcastRemoteErrorKey, "TimeInterval", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报压差异常
        /// 
        /// </summary>
        public static bool BroadcastPressureInterval
        {
            get
            {
                return ini.ReadBool(BroadcastPressureIntervalKey, "Enable", false);
            }
            set
            {
                ini.Write(BroadcastPressureIntervalKey, "Enable", value);
                ini.UpdateFile();
            }
            #endregion
        }


        /// <summary> 压差异常间隔
        /// 
        /// </summary>
        public static int PressureIntervalRange
        {
            get
            {
                return ini.ReadInt(BroadcastPressureIntervalKey, "Range", 5);
            }
            set
            {
                ini.Write(BroadcastPressureIntervalKey, "Range", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 压差异常间隔事件
        /// 
        /// </summary>
        public static int PressureIntervalTime
        {
            get
            {
                return ini.ReadInt(BroadcastPressureIntervalKey, "TimeInterval", 5);
            }
            set
            {
                ini.Write(BroadcastPressureIntervalKey, "TimeInterval", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报启动
        /// 
        /// </summary>
        public static bool BroadcastStart
        {
            get
            {
                return ini.ReadBool(BroadcastStartKey, "Enable", false);
            }
            set
            {
                ini.Write(BroadcastStartKey, "Enable", value);
                ini.UpdateFile();
            }

        }
        
    }
}
